
import request from '../../utils/request'


//订单查询
interface IOrderQuery{
    saleOrganizationID:string
    shopID:string
    memberPhoneNumber?:string
    number?:string //订单编号
    strTime?:string 
    endTime?:string
    

}
export  function orderQuery(params:IOrderQuery) {
  return request({
    url: '/sale/order/getOrder',
    method: 'get',
    params
   
  })
}

//订单详情
export  function getOrderDesc(saleOrganizationID:string,shopID:string,orderID:string) {
  return request({
    url: '/sale/order/getOrderDetail',
    method: 'get',
    params:{saleOrganizationID,shopID,orderID}
   
  })
}



interface IOrderRefresh{
  saleOrganizationName:string
  saleOrganizationID:string
  orderID:string //订单ID
  tradeNO:string //电子支付交易单号
  shopID:string
  accountType:string //网络支付账户类型
  number:string //订单编号

}
//刷新订单
export  function refreshOrder(data:IOrderRefresh) { 
  console.log(data)
  return request({
    url: '/sale/order/pos/refreshShopAwaitingPaymentOrder',
    method: 'post',
    data
   
  })
}


interface IOrderRefound{
  saleOrganizationID:string
  orderID:string //订单id
  saleOrganizationName:string
  isAllRefund:string //是否全部退货(y是 n否)
  refundGoodsAddDtos:Array<IRefundGoodsAddDtos> //退货商品集合

}

interface IRefundGoodsAddDtos{
  orderDetailID:string  //订单详情ID 
  goodsID:string 
  goodsName:string
  saleUnitID_K:string
  inventoryUnitID_K:string
  saleUnit:string //销售单位（文字）
  inventoryUnit:string //库存单位（文字）
  buyingPrice:string //进货价
  quantity:string //退货数量（重量）
  number:string //订单件数
  basicPrice:string //商品基础价格
  refundAmount:string //退货金额

  discountAmount:string //退货优惠总金额（activityDiscount + couponDiscount）
  activityDiscount:string //活动优惠额度（加权平均活动优惠)
  couponDiscount:string //优惠券优惠额度（加权平均活动优惠）
}


//退款
export  function refundOrder(data:IOrderRefound) { 
  return request({
    url: '/sale/order/refundOrder',
    method: 'post',
    data
   
  })
}
